import React, { Component } from "react";

import Modal from "./Modal";

class App extends Component {
  state = {
    show: false,
  };
  open = () => {
    this.setState({
      show: true,
    });
  };

  handleOk = () => {
    console.log("handleOk");
    this.setState({
      show: false,
    });
  };

  handleCancel = () => {
    console.log("handleCancel");
    this.setState({
      show: false,
    });
  };

  render() {
    return (
      <div>
        <h2>模态框组件封装</h2>
        <button onClick={this.open}>打开</button>
        {/* {this.state.show && <Modal />} */}

        <Modal
          open={this.state.show}
          title="modal title"
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          cancelText="关闭"
          okText="提交"
          width="500"
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </div>
    );
  }
}

export default App;
